
cmake_minimum_required(VERSION 2.8)

#--- имя проекта совпадает с именем каталога проекта
get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)

#--- имя главной цели. CXX значает, что проект на с++
project( ${PROJECT_NAME} CXX )

#----- настройки компиляции
include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/setup.cmake)

#----- добавление компонентов библиотеки
include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/add_component.cmake)

#------------------ добавляем основные исходники проекта ---------------------------------------------
get_filename_component(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}" ABSOLUTE)
get_filename_component(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src"                      ABSOLUTE)
add_component( ${PROJECT_NAME} )

#------------------ наполнение проекта  --------------------------------------------------------------
include (${CMAKE_CURRENT_SOURCE_DIR}/content.cmake)

#------------------ пути к хэдерам -------------------------------------------------------------------
set (PATH_INCLUDES
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)

#----------------------------------------------
include_directories( ${PATH_INCLUDES} )
link_directories   ( ${PATH_LIB}      )

# message(STATUS "============================================================" )
# view_console("caption:BOOST FOUND"  ${BOOST_ROOT} )
# view_console("caption:LIBRARY_DIRS" ${PATH_LIB} )
# view_console("caption:INCLUDE_DIRS" ${PATH_INCLUDES} )
# view_console("caption:LIBRARIES"    ${LIBRARIES} )
# view_console("caption:FILES"        ${PRODUCT_SOURCES_FILES} )
# message(STATUS "============================================================" )
#----------------------------------------------------------------------------

#--------------------- чем является цель: приложение, библиотека, тп ---------------------------------
if(THIS_TARGET STREQUAL "executable")
    add_executable (${PROJECT_NAME}  ${PRODUCT_SOURCES_FILES} )
else()
    set(PROJECT_NAME ${PROJECT_NAME}-${ADDRESS_MODEL}${MY_DEBUG_MARKER})
    add_library (${PROJECT_NAME}  STATIC ${PRODUCT_SOURCES_FILES} )
endif()

#------------------------ устанавливаем имя pdb файла собранной цели ---------------------------------
set(file_pdb ${CMAKE_BUILD_TYPE}/${PROJECT_NAME}.pdb )
set_target_properties(${PROJECT_NAME}
    PROPERTIES
    COMPILE_FLAGS "/Fd\"${file_pdb}\""
) 


#----------------------- линкуем проект со всеми внешними библиотеками -------------------------------
target_link_libraries (${PROJECT_NAME} ${LIBRARIES})
target_link_libraries (${PROJECT_NAME} ${LIBRARIES})
